﻿using Architecture.Api.Application.Commands.LoginCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domian.DTO;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.LoginHandler
{
    public class LoginCommandHandler : IRequestHandler<LoginCommand, CodeDto>
    {
        private readonly IUserService _userService;

        public LoginCommandHandler(IUserService userService)
        {
            _userService = userService;
        }

        public async Task<CodeDto> Handle(LoginCommand request, CancellationToken cancellationToken)
        {
            return await _userService.Login(new UserDTO
            {
                loginName = request.loginName,
                passWord = request.passWord,
            });
        }
    }
}
